<template>
	<view class="page">
		<view class="inp">
			<u-input v-model="query.carNumber" fontSize="12" border="surround" placeholder="搜索车牌号">
				<template slot="prefix">
					<u-icon name="search" color="#9e9e9e" size="24"></u-icon>
				</template>
			</u-input>
			<view style="width: 120rpx; text-align: center;" @click="getCarManagerPage">搜索</view>
		</view>
		<dropdown-list :show="shows" :top="94" :height="280">
			<template v-slot:selectionbox>
				<view class="top">
					<view class="top-name" @click="dropDownList(-1)">
						<view>{{orders}}</view>
						<u-icon name="arrow-down"></u-icon>
						<u-line length="16" direction="col" margin="0rpx 20rpx"></u-line>
					</view>
				</view>
			</template>
			<template v-slot:dropdownbox>
				<view class="tui-selected-list">
					<scroll-view scroll-y class="tui-dropdown-scroll">
						<block v-for="(item,index) in dropdownlistData" :key="index">
							<!-- <tui-list-cell padding="0"
								:unlined="dropdownlistData.length-1==index"> -->
							<view class="tui-cell-class" @click="dropDownList(item)">
								<text class="tui-ml-20">{{item.name}}</text>
							</view>
							<!-- </tui-list-cell> -->
						</block>
					</scroll-view>
				</view>
			</template>
		</dropdown-list>

		<view style="font-size: 24rpx; margin: 20rpx;">共<text style="color:#257CFF">{{total}}</text>条数据</view>

		<view class="content" v-for="item in carList">
			<view class="order">
				<image class="img" :src="item.seriesImage"></image>
				<view class="content1">
					<view class="content-name">{{item.carNumber}} / {{item.carTypeText}}</view>
					<view class="content-map">品牌型号：{{item.seriesName}}</view>
					<view class="content-map">运营时长：{{item.operationYear}}年</view>
					<view class="content-map">年度维修费用：{{item.expenses}}元</view>
				</view>
			</view>
			<u-line color="#ececec"></u-line>
			<view :class='item.operationStatus===1?"butBlue":"but"'>
				<view>{{item.operationStatus===1?"运营中":"维保中"}}</view>
				<view class="button"
					@click="$goBack(2,'/bundle/pages/companyLookCarDetail/companyLookCarDetail?carId='+item.id)">查看详情
				</view>
			</view>
		</view>
		<u-loading-page loading-text="加载中" :loading="loading"></u-loading-page>
		<u-empty v-if="carList.length==0" text="暂无数据">
		</u-empty>
		<u-action-sheet :actions="list" @select="selectClick" :show="show"></u-action-sheet>
	</view>
</template>

<script>
	import DropdownList from '../../../components/tui-dropdown-list/tui-dropdown-list.vue'


	import {
		apiGetCarManagerPage
	} from '@/api/car.js'
	export default {
		components: {
			DropdownList
		},
		data() {
			return {
				list: [{
						name: '选项一'
					},
					{
						name: '选项二'
					}
				],
				query: {
					current: 1,
					size: 10,
					carNumber: null,
					operationStatus:''
				},
				show: false,
				carList: [],
				total: 0,
				value: null,
				loading: true,
				shows: false,
				orders: '车辆状态',
				dropdownlistData: [{
						name: '全部状态',
						operationStatus: null
					},
					{
						name: "运营中",
						operationStatus: 1
					},
					{
						name: "维保中",
						operationStatus: 2
					},

				],
			}
		},
		created() {
			this.getCarManagerPage();
		},
		methods: {
			dropDownList(item) {
				if (item == -1) {
					this.shows = !this.shows
					return
					// this.tui.toast("index：" + index)
				}
				this.orders = item.name
				console.log(item)
				this.query.operationStatus=item.operationStatus
				this.getCarManagerPage()
				this.loading=true
				this.shows = !this.shows
			},
			selectClick(e) {
				this.show = false
			},
			getCarManagerPage() {
				
				apiGetCarManagerPage(this.query).then(res => {
					this.carList = res.data.records;
					this.total = res.data.total
					this.loading = false
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.tui-drop-input-box {
		padding: 50rpx;
		box-sizing: border-box;
	}

	.tui-animation {
		display: inline-block;
		transform: rotate(0deg);
		transition: all 0.2s;
	}

	.tui-animation-show {
		transform: rotate(180deg);
	}

	.tui-selected-list {
		background-color: #fff;
		border-radius: 20rpx;
		overflow: hidden;
		transform: translateZ(0);
	}

	.tui-dropdown-scroll {
		height: 400rpx;
	}

	.tui-cell-class {
		display: flex;
		align-items: center;
		padding: 26rpx 30rpx !important;
	}

	.tui-ml-20 {
		margin-left: 20rpx;
		font-size: 24rpx
	}

	.inp {
		box-sizing: border-box;
		padding: 20rpx;
		background-color: #fff;
		@include flex(row, space-between, center) font-size: 30rpx;
	}

	.top {
		padding: 20rpx;
		height: 84rpx;
		font-size: 28rpx;
		background-color: #fff;
		text-align: center;

		@include flex(row, space-between, center) .top-name {

			display: flex;
		}
	}

	.content {
		width: 718rpx;
		// height: 360rpx;
		margin: 16rpx;
		padding: 10rpx 20rpx;
		box-sizing: border-box;
		background-color: #fff;
		border-radius: 20rpx;


		.order {
			margin: 20rpx 10rpx;
			display: flex;

			.img {
				border-radius: 10rpx;
				width: 216rpx;
				height: 216rpx;
			}

			.content1 {
				width: 440rpx;
				margin-left: 20rpx;
				line-height: 50rpx;


				.content-name {
					font-size: 28rpx;
					font-weight: 600;
				}

				.content-map {
					font-size: 28rpx;
				}
			}
		}

		.store {
			font-size: 26rpx;
			margin: 8rpx 0rpx;
		}

		.order-content {
			width: 666rpx;
			font-size: 24rpx;
			color: #666666;
			margin-bottom: 6rpx;
		}

		.time {
			margin-bottom: 8rpx;
			color: #949494;
			font-size: 24rpx;
		}

		.but {
			color: #FF1616;
			margin-top: 16rpx;
			font-size: 28rpx;

			@include flex(row, space-between, center) .button {
				color: #257CFF;
			}
		}

		.butBlue {
			color: #00aaff;
			margin-top: 16rpx;
			font-size: 28rpx;

			@include flex(row, space-between, center) .button {
				color: #257CFF;
			}
		}
	}

	::v-deep .u-transition {
		// position: absolute !important; 
		top: 200rpx !important;
	}

	::v-deep .u-input {
		height: 40rpx;
		margin: 0rpx 40rpx -10rpx 32rpx;
		background-color: #efefef !important;

	}
</style>